package 对撞指针;

public class LeetCode167_两数之和 {
    public int[] twoSum(int[] numbers, int target) {
        int i = 0;
        int j = numbers.length - 1;
        int[] resault = new int[2];
        while(true) {
            if(numbers[i] + numbers[j] == target) {
                resault[0] = i + 1;
                resault[1] = j + 1;
                break;
            }else if(numbers[i] + numbers[j] < target){
                i++;
            }else{
                j--;
            }
        }
        return resault;
    }
}
